<!--继承模板-->
{% extends 'base.html' %}
{% block app_content %}
    <h1>Hi,{{ current_user.username }}!</h1>
    <!--添加一个发布动态的表单   附加只有在传入表单参数后才会显示表单-->
    {% if form %}
    <form action="" method="post">
        {{ form.hidden_tag() }}
        <p>
            {{ form.post.label }}<br>
            {{ form.post(cols=32,rows=4) }}<br>
            {% for error in form.post.errors %}
                <span style="color: red">[{{ error }}]</span>
            {% endfor %}
        </p>
        <p>{{ form.submit() }}</p>
    </form>
    {% endif %}
    {% for post in posts %}
        {% include '_post.html' %}
    <!--    <div><p>{{ post.author.username }} says: <b>{{ post.body }}</b></p></div>-->
    {% endfor %}
    <!--分页链接-->
{#    {% if prev_url %}#}
{#        <a href="{{ prev_url }}">后一页</a>#}
{#    {% endif %}#}
{#    {% if next_url %}#}
{#        <a href="{{ next_url }}">前一页</a>#}
{#    {% endif %}#}
    <nav aria-label="...">
        <ul class="pager">
            <li class="previous {% if not prev_url %} disabled {% endif %}">
                <a href="{{ prev_url or "#" }}">
                    <span aria-hidden="true">&larr;</span>Newer posts
                </a>
            </li>
            <li class="next{% if not next_url %} disabled {% endif %}">
                <a href="{{ next_url or "#" }}">
                    Older posts <span aria-hidden="true">&rarr;</span>
                </a>
            </li>
        </ul>
    </nav>
{% endblock %}